﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



using HA.Data;
using HAVTKPack;
using HA.ModFlow.Infrastructure;
using HA.ModFlow.Domain.DomainLayer;

namespace HA.ModFlow.Application
{

    /// <summary>
    /// Modflow的Node的管理：添加Node，删除Node，更新Node等等
    /// </summary>
    public static class ModflowNodeManager
    {

        #region Modflow的Node的：添加，删除，高程，IBound，IJK，Z轴缩放   等等

        public static void AddModflowNode(Scene vtkScene, double scaleZ)
        {

            if (scaleZ < 0)
            {
                scaleZ = 1;
            }


            Project project = ProjectService.DefaultService.Project;

            if (project != null)
            {
                if (project.Grid3dData != null)
                {
                    if (project.Grid3dData.Grids != null)
                    {
                        if (project.Grid3dData.Grids.Count > 0)//主程序还没有建立任何网格
                        {
                            if (vtkScene != null)
                            {
                                if (ProjectService.DefaultService.Project.MfData != null)//主程序还没有建立Modflow
                                {

                                    Grid3d gd = project.Grid3dData.MainGrid;//得到主程序建立的网格信息

                                    HydrolicGrid hgHead = AlgorithmHelper.ConvertToHydroGrid(gd.ModFlowGrid.GetHeadGrid());



                                    #region 添加IBound有效单元标志Node


                                    GeometryNode gnIBound = new GeometryNode(ModFlowNodeIDManager.gridIBoundEffective.ToString(), new HydrolicHeadGeometry(hgHead, gd.ModFlowGrid.WaterGrid.GetIBounds()));


                                    Vector newVector = new Vector(1, 1, scaleZ);
                                    //((HydrolicHeadGeometry)gnIBound.Geometry).UpdateTransformScale(newVector);
                                    gnIBound.Scale = newVector;


                                    //配置信息
                                    System.Drawing.Color colorIBound = System.Drawing.Color.Red;
                                    int solidSizeIBOund = 1;
                                    vtkGlyphSource2DDrawType drawTypeIBound = vtkGlyphSource2DDrawType.Square;
                                    //if (project.DisplayOption.Modflow.ConstantHead !=null )
                                    //{
                                    //     colorIBound = project.DisplayOption.Modflow.ConstantHead.Color;
                                    //     solidSizeIBOund = project.DisplayOption.Modflow.ConstantHead.Size;
                                    //     drawTypeIBound = GetGlyphDrawType(project.DisplayOption.Modflow.ConstantHead.DisplayShape);
                                    //}

                                    if (project.DisplayOption2.DoGrid3dData != null && project.DisplayOption2.DoGrid3dData.Modflow != null && project.DisplayOption2.DoGrid3dData.Modflow.ConstantHead != null)
                                    {
                                        colorIBound = project.DisplayOption2.DoGrid3dData.Modflow.ConstantHead.Color;
                                        solidSizeIBOund = project.DisplayOption2.DoGrid3dData.Modflow.ConstantHead.Size;
                                        drawTypeIBound = GetGlyphDrawType(project.DisplayOption2.DoGrid3dData.Modflow.ConstantHead.DisplayShape);
                                    }

                                    gnIBound.AddFilter(new ShowHeadFilter(FilterIDManager.effectiveIBound.ToString(), solidSizeIBOund, colorIBound, drawTypeIBound));

                                    vtkScene.AddNode(gnIBound);


                                    #endregion



                                    #region 添加源汇项Node


                                    List<int[]> ijks = new List<int[]>();

                                    if (ProjectService.DefaultService.Project.MfData != null)
                                    {
                                        foreach (Well item in ProjectService.DefaultService.Project.MfData.SourceSinks.Wells.InnerList)
                                        {
                                            ijks.Add(new int[] { item.I, item.J, item.K, item.Index });
                                        }
                                    }

                                    //Well的表现

                                    GeometryNode gnWell = new GeometryNode(ModFlowNodeIDManager.gridWell.ToString(), new HydrolicSourceSinksGeometry(hgHead, gd.ModFlowGrid.WaterGrid.GetIBounds(), ijks));


                                    gnWell.Scale = newVector;
                                    //((HydrolicSourceSinksGeometry)gnWell.Geometry).UpdateTransformScale(newVector);

                                    //配置信息

                                    System.Drawing.Color colorWell = System.Drawing.Color.Red;
                                    int solidSizeWell = 1;
                                    vtkGlyphSource2DDrawType drawTypeWell = vtkGlyphSource2DDrawType.Square;

                                    //if (project.DisplayOption.Modflow.Wells  != null)
                                    //{
                                    //    colorWell = project.DisplayOption.Modflow.Wells.Color;
                                    //    solidSizeWell = project.DisplayOption.Modflow.Wells.Size;
                                    //    drawTypeWell = GetGlyphDrawType(project.DisplayOption.Modflow.Wells.DisplayShape);
                                    //}


                                    if (project.DisplayOption2.DoGrid3dData != null && project.DisplayOption2.DoGrid3dData.Modflow != null)
                                    {
                                        colorWell = project.DisplayOption2.DoGrid3dData.Modflow.Wells.Color;
                                        solidSizeWell = project.DisplayOption2.DoGrid3dData.Modflow.Wells.Size;
                                        drawTypeWell = GetGlyphDrawType(project.DisplayOption2.DoGrid3dData.Modflow.Wells.DisplayShape);
                                    }




                                    gnWell.AddFilter(new ShowWellFilter(FilterIDManager.showWellFilter.ToString(), solidSizeWell, colorWell, drawTypeWell));

                                    vtkScene.AddNode(gnWell);






                                    ijks = new List<int[]>();

                                    if (ProjectService.DefaultService.Project.MfData != null)
                                    {
                                        foreach (River item in ProjectService.DefaultService.Project.MfData.SourceSinks.Rivers.InnerList)
                                        {
                                            ijks.Add(new int[] { item.I, item.J, item.K, item.Index });
                                        }
                                    }

                                    //River的表现

                                    GeometryNode gnRiver = new GeometryNode(ModFlowNodeIDManager.gridRiver.ToString(), new HydrolicSourceSinksGeometry(hgHead, gd.ModFlowGrid.WaterGrid.GetIBounds(), ijks));


                                    gnRiver.Scale = newVector;
                                    //((HydrolicSourceSinksGeometry)gnRiver.Geometry).UpdateTransformScale(newVector);


                                    //配置信息

                                    System.Drawing.Color colorRiver = System.Drawing.Color.Red;
                                    int solidSizeRiver = 1;
                                    vtkGlyphSource2DDrawType drawTypeRiver = vtkGlyphSource2DDrawType.Square;
                                    //if (project.DisplayOption.Modflow.Rivers  != null)
                                    //{
                                    //    colorRiver = project.DisplayOption.Modflow.Rivers.Color;
                                    //    solidSizeRiver = project.DisplayOption.Modflow.Rivers.Size;
                                    //    drawTypeRiver = GetGlyphDrawType(project.DisplayOption.Modflow.Rivers.DisplayShape);
                                    //}


                                    if (project.DisplayOption2.DoGrid3dData != null && project.DisplayOption2.DoGrid3dData.Modflow != null)
                                    {
                                        colorRiver = project.DisplayOption2.DoGrid3dData.Modflow.Rivers.Color;
                                        solidSizeRiver = project.DisplayOption2.DoGrid3dData.Modflow.Rivers.Size;
                                        drawTypeRiver = GetGlyphDrawType(project.DisplayOption2.DoGrid3dData.Modflow.Rivers.DisplayShape);
                                    }



                                    gnRiver.AddFilter(new ShowRiverFilter(FilterIDManager.showRiverFilter.ToString(), solidSizeRiver, colorRiver, drawTypeRiver));

                                    vtkScene.AddNode(gnRiver);







                                    ijks = new List<int[]>();

                                    if (ProjectService.DefaultService.Project.MfData != null)
                                    {
                                        foreach (Drain item in ProjectService.DefaultService.Project.MfData.SourceSinks.Drains.InnerList)
                                        {
                                            ijks.Add(new int[] { item.I, item.J, item.K, item.Index });
                                        }
                                    }

                                    //River的表现

                                    GeometryNode gnDrain = new GeometryNode(ModFlowNodeIDManager.gridDrain.ToString(), new HydrolicSourceSinksGeometry(hgHead, gd.ModFlowGrid.WaterGrid.GetIBounds(), ijks));

                                    gnDrain.Scale = newVector;
                                    //((HydrolicSourceSinksGeometry)gnDrain.Geometry).UpdateTransformScale(newVector);

                                    //配置信息

                                    System.Drawing.Color colorDrain = System.Drawing.Color.Red;
                                    int solidSizeDrain = 1;
                                    vtkGlyphSource2DDrawType drawTypeDrain = vtkGlyphSource2DDrawType.Square;
                                    //if (project.DisplayOption.Modflow.Drains  != null)
                                    //{
                                    //    colorDrain = project.DisplayOption.Modflow.Drains.Color;
                                    //    solidSizeDrain = project.DisplayOption.Modflow.Drains.Size;
                                    //    drawTypeDrain = GetGlyphDrawType(project.DisplayOption.Modflow.Drains.DisplayShape);
                                    //}


                                    if (project.DisplayOption2.DoGrid3dData != null && project.DisplayOption2.DoGrid3dData.Modflow != null)
                                    {
                                        colorDrain = project.DisplayOption2.DoGrid3dData.Modflow.Drains.Color;
                                        solidSizeDrain = project.DisplayOption2.DoGrid3dData.Modflow.Drains.Size;
                                        drawTypeDrain = GetGlyphDrawType(project.DisplayOption2.DoGrid3dData.Modflow.Drains.DisplayShape);
                                    }



                                    gnDrain.AddFilter(new ShowDrainFilter(FilterIDManager.showDrainFilter.ToString(), solidSizeDrain, colorDrain, drawTypeDrain));

                                    vtkScene.AddNode(gnDrain);







                                    ijks = new List<int[]>();

                                    if (ProjectService.DefaultService.Project.MfData != null)
                                    {
                                        foreach (GeneralHead item in ProjectService.DefaultService.Project.MfData.SourceSinks.GeneralHeads.InnerList)
                                        {
                                            ijks.Add(new int[] { item.I, item.J, item.K, item.Index });
                                        }
                                    }
                                    //River的表现

                                    GeometryNode gnGeneralHead = new GeometryNode(ModFlowNodeIDManager.gridGeneralHead.ToString(), new HydrolicSourceSinksGeometry(hgHead, gd.ModFlowGrid.WaterGrid.GetIBounds(), ijks));



                                    gnGeneralHead.Scale = newVector;
                                    //((HydrolicSourceSinksGeometry)gnGeneralHead.Geometry).UpdateTransformScale(newVector);



                                    //配置信息

                                    System.Drawing.Color colorGeneralHead = System.Drawing.Color.Red;
                                    int solidSizeGeneralHead = 1;
                                    vtkGlyphSource2DDrawType drawTypeGeneralHead = vtkGlyphSource2DDrawType.Square;
                                    //if (project.DisplayOption.Modflow.GeneralHead  != null)
                                    //{
                                    //    colorGeneralHead = project.DisplayOption.Modflow.GeneralHead.Color;
                                    //    solidSizeGeneralHead = project.DisplayOption.Modflow.GeneralHead.Size;
                                    //    drawTypeGeneralHead = GetGlyphDrawType(project.DisplayOption.Modflow.GeneralHead.DisplayShape);
                                    //}


                                    if (project.DisplayOption2.DoGrid3dData != null && project.DisplayOption2.DoGrid3dData.Modflow != null)
                                    {
                                        colorGeneralHead = project.DisplayOption2.DoGrid3dData.Modflow.GeneralHead.Color;
                                        solidSizeGeneralHead = project.DisplayOption2.DoGrid3dData.Modflow.GeneralHead.Size;
                                        drawTypeGeneralHead = GetGlyphDrawType(project.DisplayOption2.DoGrid3dData.Modflow.GeneralHead.DisplayShape);
                                    }




                                    gnGeneralHead.AddFilter(new ShowGeneralHeadFilter(FilterIDManager.showGeneralHead.ToString(), solidSizeGeneralHead, colorGeneralHead, drawTypeGeneralHead));

                                    vtkScene.AddNode(gnGeneralHead);





                                    ijks = new List<int[]>();

                                    if (ProjectService.DefaultService.Project.MfData != null)
                                    {
                                        foreach (SpecifiedHead item in ProjectService.DefaultService.Project.MfData.SourceSinks.SpecifiedHeads.InnerList)
                                        {
                                            ijks.Add(new int[] { item.I, item.J, item.K, item.Index });
                                        }
                                    }
                                    //River的表现

                                    GeometryNode gnSpecifiedHead = new GeometryNode(ModFlowNodeIDManager.gridSpedifiedHead.ToString(), new HydrolicSourceSinksGeometry(hgHead, gd.ModFlowGrid.WaterGrid.GetIBounds(), ijks));

                                    gnSpecifiedHead.Scale = newVector;
                                    //((HydrolicSourceSinksGeometry)gnSpecifiedHead.Geometry).UpdateTransformScale(newVector);



                                    //配置信息

                                    System.Drawing.Color colorSpecifiedHead = System.Drawing.Color.Red;
                                    int solidSizeSpecifiedHead = 1;
                                    vtkGlyphSource2DDrawType drawTypeSpecifiedHead = vtkGlyphSource2DDrawType.Square;
                                    //if (project.DisplayOption.Modflow.TransientData  != null)
                                    //{
                                    //    colorSpecifiedHead = project.DisplayOption.Modflow.TransientData.Color;
                                    //    solidSizeSpecifiedHead = project.DisplayOption.Modflow.TransientData.Size;
                                    //    drawTypeSpecifiedHead = GetGlyphDrawType(project.DisplayOption.Modflow.TransientData.DisplayShape);
                                    //}





                                    if (project.DisplayOption2.DoGrid3dData != null && project.DisplayOption2.DoGrid3dData.Modflow != null)
                                    {
                                        colorSpecifiedHead = project.DisplayOption2.DoGrid3dData.Modflow.TransientData.Color;
                                        solidSizeSpecifiedHead = project.DisplayOption2.DoGrid3dData.Modflow.TransientData.Size;
                                        drawTypeSpecifiedHead = GetGlyphDrawType(project.DisplayOption2.DoGrid3dData.Modflow.TransientData.DisplayShape);
                                    }



                                    gnSpecifiedHead.AddFilter(new ShowSpecifiedHeadFilter(FilterIDManager.showSpecifiedHead.ToString(), solidSizeSpecifiedHead, colorSpecifiedHead, drawTypeSpecifiedHead));

                                    vtkScene.AddNode(gnSpecifiedHead);





                                    #endregion



                                    #region 添加Barrier



                                    List<PlaneBarrierData> barrierCellIJK = new List<PlaneBarrierData>();//数据信息
                                    //从主程序取得barrier数据
                                    #region
                                    if (project.MfData.HfbData != null)
                                    {
                                        if (project.MfData.HfbData.HfbList != null)
                                        {
                                            for (int i = 0; i < project.MfData.HfbData.HfbList.Count; i++)
                                            {
                                                if (project.MfData.HfbData.HfbList[i] != null)
                                                {
                                                    PlaneBarrierData barrierData = new PlaneBarrierData();
                                                    HFBItem hfbItem = project.MfData.HfbData.HfbList[i];

                                                    barrierData.IROW1 = hfbItem.IROW1;
                                                    barrierData.ICOL1 = hfbItem.ICOL1;
                                                    barrierData.IROW2 = hfbItem.IROW2;
                                                    barrierData.ICOL2 = hfbItem.ICOL2;
                                                    barrierData.Layer = hfbItem.Layer;
                                                    barrierData.Hydchr = hfbItem.Hydchr;
                                                    barrierData.Factor = hfbItem.Factor;

                                                    barrierCellIJK.Add(barrierData);

                                                }
                                                else
                                                {
                                                    barrierCellIJK = new List<PlaneBarrierData>();

                                                    break;

                                                }

                                            }
                                        }
                                    }
                                    #endregion


                                    HydrolicGrid planeBarrier = AlgorithmHelper.ConvertToHydroGrid(gd.ModFlowGrid.GetBoundGrid());
                                    GeometryNode gnPlaneBarrier = new GeometryNode(ModFlowNodeIDManager.gridPlaneBarrier.ToString(), new HydrolicPlaneBarrierGeometry(planeBarrier, gd.ModFlowGrid.WaterGrid.GetIBounds(), barrierCellIJK));

                                    gnPlaneBarrier.Scale = newVector;//z缩放  由Node负责
                                    //((HydrolicPlaneBarrierGeometry)gnPlaneBarrier.Geometry).ScaleVector = newVector;


                                    //配置信息
                                    System.Drawing.Color color = System.Drawing.Color.Red;
                                    int solidWidth = 1;
                                    //if (project.DisplayOption.Modflow.HorizFlowBarrier!=null )
                                    //{
                                    //     color = project.DisplayOption.Modflow.HorizFlowBarrier.Color;
                                    //     solidWidth = project.DisplayOption.Modflow.HorizFlowBarrier.Size;
                                    //}


                                    if (project.DisplayOption2.DoGrid3dData != null && project.DisplayOption2.DoGrid3dData.Modflow != null)
                                    {
                                        color = project.DisplayOption2.DoGrid3dData.Modflow.HorizFlowBarrier.Color;
                                        solidWidth = project.DisplayOption2.DoGrid3dData.Modflow.HorizFlowBarrier.Size;
                                    }


                                    gnPlaneBarrier.AddFilter(new ShowPlaneBarrierFilter(FilterIDManager.showPlaneBarrierFilter.ToString(), color, solidWidth));



                                    vtkScene.AddNode(gnPlaneBarrier);



                                    #endregion




                                }
                            }

                        }

                    }
                }
            }





        }


        public static void DeleteModflowNode(Scene vtkScene)
        {

            if (vtkScene != null)
            {

                #region 删除水头Node

                vtkScene.RemoveNode(ModFlowNodeIDManager.gridIBoundEffective.ToString());

                #endregion

                #region 删除源汇项Node

                vtkScene.RemoveNode(ModFlowNodeIDManager.gridWell.ToString());
                vtkScene.RemoveNode(ModFlowNodeIDManager.gridRiver.ToString());
                vtkScene.RemoveNode(ModFlowNodeIDManager.gridDrain.ToString());
                vtkScene.RemoveNode(ModFlowNodeIDManager.gridGeneralHead.ToString());
                vtkScene.RemoveNode(ModFlowNodeIDManager.gridSpedifiedHead.ToString());


                //this._vtkScene.RemoveNode("gridheadwell");
                //this._vtkScene.RemoveNode("gridheadriver");
                //this._vtkScene.RemoveNode("gridheaddrain");
                //this._vtkScene.RemoveNode("gridheadgeneralhead");
                //this._vtkScene.RemoveNode("gridheadspedifiedhead");



                #endregion


                #region 删除planeBarrier

                vtkScene.RemoveNode(ModFlowNodeIDManager.gridPlaneBarrier.ToString());

                #endregion





            }



        }


        public static void UpdateGeometryElevation(Scene vtkScene, GridData gridData)
        {
            if (vtkScene == null || gridData == null)
            {
                return;
            }
            HeadGrid headGrid = gridData.GetHeadGrid();
            if (headGrid == null)
            {
                return;
            }
            BoundGrid boundGrid = gridData.GetBoundGrid();
            if (boundGrid == null)
            {
                return;
            }

            HydrolicGrid hgHead = AlgorithmHelper.ConvertToHydroGrid(gridData.GetHeadGrid());

            HydrolicGrid hgBound = AlgorithmHelper.ConvertToHydroGrid(gridData.GetBoundGrid());

            #region HeadGrid

            //IBound有效性Node
            if (vtkScene.GetNode(ModFlowNodeIDManager.gridIBoundEffective.ToString()) != null)
            {
                ((HydrolicHeadGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridIBoundEffective.ToString())).Geometry)).Hg = hgHead;
            }


            // 源汇项  网格单元Well，Drain等的标志符号

            if (vtkScene.GetNode(ModFlowNodeIDManager.gridWell.ToString()) != null)
            {
                ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridWell.ToString())).Geometry)).Hg = hgHead;
            }


            if (vtkScene.GetNode(ModFlowNodeIDManager.gridRiver.ToString()) != null)
            {
                ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridRiver.ToString())).Geometry)).Hg = hgHead;
            }



            if (vtkScene.GetNode(ModFlowNodeIDManager.gridDrain.ToString()) != null)
            {
                ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridDrain.ToString())).Geometry)).Hg = hgHead;
            }



            if (vtkScene.GetNode(ModFlowNodeIDManager.gridGeneralHead.ToString()) != null)
            {
                ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridGeneralHead.ToString())).Geometry)).Hg = hgHead;
            }



            if (vtkScene.GetNode(ModFlowNodeIDManager.gridSpedifiedHead.ToString()) != null)
            {
                ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridSpedifiedHead.ToString())).Geometry)).Hg = hgHead;
            }





            #endregion


            #region PlaneBarrier

            if (vtkScene.GetNode(ModFlowNodeIDManager.gridPlaneBarrier.ToString()) != null)
            {
                ((HydrolicPlaneBarrierGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridPlaneBarrier.ToString())).Geometry)).Hg = hgBound;
            }


            #endregion



        }


        public static void UpdateGeometryIBound(Scene vtkScene, List<int[,]> effectSign)
        {

            if (vtkScene == null || effectSign == null)
            {
                return;
            }


            //IBound有效性表现的Node

            if (vtkScene.GetNode(ModFlowNodeIDManager.gridIBoundEffective.ToString()) != null)
            {
                ((HydrolicHeadGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridIBoundEffective.ToString())).Geometry)).EffectiveSign1 = effectSign;
            }


            //  源汇项  网格单元Well，Drain等的标志符号
            if (vtkScene.GetNode(ModFlowNodeIDManager.gridWell.ToString()) != null)
            {
                ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridWell.ToString())).Geometry)).EffectiveSign1 = effectSign;
            }

            if (vtkScene.GetNode(ModFlowNodeIDManager.gridRiver.ToString()) != null)
            {
                ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridRiver.ToString())).Geometry)).EffectiveSign1 = effectSign;
            }

            if (vtkScene.GetNode(ModFlowNodeIDManager.gridDrain.ToString()) != null)
            {
                ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridDrain.ToString())).Geometry)).EffectiveSign1 = effectSign;
            }

            if (vtkScene.GetNode(ModFlowNodeIDManager.gridGeneralHead.ToString()) != null)
            {
                ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridGeneralHead.ToString())).Geometry)).EffectiveSign1 = effectSign;

            }

            if (vtkScene.GetNode(ModFlowNodeIDManager.gridSpedifiedHead.ToString()) != null)
            {
                ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridSpedifiedHead.ToString())).Geometry)).EffectiveSign1 = effectSign;
            }


            //屏障
            if (vtkScene.GetNode(ModFlowNodeIDManager.gridPlaneBarrier.ToString()) != null)
            {
                ((HydrolicPlaneBarrierGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridPlaneBarrier.ToString())).Geometry)).EffectiveSign = effectSign;
            }



        }


        public static void UpdatePlaneBarrierIJKIndex(Scene vtkScene, ModFlowNodeIDManager nodeID, List<PlaneBarrierData> barrierIJKData)
        {
            if (vtkScene == null)
            {
                return;
            }

            switch (nodeID)
            {

                case ModFlowNodeIDManager.gridPlaneBarrier:
                    if (vtkScene.GetNode(ModFlowNodeIDManager.gridPlaneBarrier.ToString()) != null)
                    {
                        ((HydrolicPlaneBarrierGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridPlaneBarrier.ToString())).Geometry)).BarrierCellIJK = barrierIJKData;
                    }


                    break;

                case ModFlowNodeIDManager.gridIBoundEffective:
                    break;
                case ModFlowNodeIDManager.gridWell:
                    break;
                case ModFlowNodeIDManager.gridRiver:
                    break;
                case ModFlowNodeIDManager.gridDrain:
                    break;
                case ModFlowNodeIDManager.gridGeneralHead:
                    break;
                case ModFlowNodeIDManager.gridSpedifiedHead:
                    break;

                default:
                    break;
            }







        }



        public static void UpdateGeometryIJKIndex(Scene vtkScene, ModFlowNodeIDManager nodeID, List<int[]> ijks)
        {
            if (vtkScene == null || ijks == null)
            {
                return;
            }

            switch (nodeID)
            {

                case ModFlowNodeIDManager.gridIBoundEffective:

                    break;
                case ModFlowNodeIDManager.gridWell:

                    if (vtkScene.GetNode(ModFlowNodeIDManager.gridWell.ToString()) != null)
                    {
                        ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridWell.ToString())).Geometry)).Ijkindexs = ijks;
                    }


                    break;
                case ModFlowNodeIDManager.gridRiver:
                    if (vtkScene.GetNode(ModFlowNodeIDManager.gridRiver.ToString()) != null)
                    {
                        ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridRiver.ToString())).Geometry)).Ijkindexs = ijks;
                    }


                    break;
                case ModFlowNodeIDManager.gridDrain:
                    if (vtkScene.GetNode(ModFlowNodeIDManager.gridDrain.ToString()) != null)
                    {
                        ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridDrain.ToString())).Geometry)).Ijkindexs = ijks;
                    }


                    break;
                case ModFlowNodeIDManager.gridGeneralHead:
                    if (vtkScene.GetNode(ModFlowNodeIDManager.gridGeneralHead.ToString()) != null)
                    {
                        ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridGeneralHead.ToString())).Geometry)).Ijkindexs = ijks;
                    }


                    break;
                case ModFlowNodeIDManager.gridSpedifiedHead:
                    if (vtkScene.GetNode(ModFlowNodeIDManager.gridSpedifiedHead.ToString()) != null)
                    {
                        ((HydrolicSourceSinksGeometry)(((GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridSpedifiedHead.ToString())).Geometry)).Ijkindexs = ijks;
                    }


                    break;
                case ModFlowNodeIDManager.gridPlaneBarrier:

                    break;
                default:

                    break;


            }



        }




        public static void UpdateGeometryTransformZScale(Scene vtkScene, double scaleZ)
        {

            if (vtkScene == null || scaleZ < 0)
            {
                return;

            }
            if (vtkScene.NodeDic == null)
            {
                return;
            }

            HAVTKPack.Vector scale = new Vector(1, 1, scaleZ);


            //遍历所有节点 更新transform缩放

            foreach (var item in vtkScene.NodeDic)
            {

                if (item.Value.Name != GridNodeIDManager.grid.ToString())
                {

                    #region  更新节点Node的transform缩放


                    GeometryNode geometryNode = (GeometryNode)item.Value;

                    geometryNode.Scale = scale;


                    #endregion


                }

            }

        }


        #endregion


        #region Filter的配置更新


        public static void UpdateNodeGlyphSymble(Scene vtkScene, ModFlowNodeIDManager nodeID, DOEntity doEntity)
        {

            if (vtkScene == null || doEntity == null)
            {
                return;
            }



            switch (nodeID)
            {
                case ModFlowNodeIDManager.gridIBoundEffective:

                    GeometryNode gnIBound = (GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridIBoundEffective.ToString());
                    if (gnIBound != null)
                    {
                        ShowHeadFilter headFilter = (ShowHeadFilter)gnIBound.GetFilter(FilterIDManager.effectiveIBound.ToString());
                        if (headFilter != null)
                        {
                            bool isUse = doEntity.Enabled;//是不是控制  Actor 的可见性
                            int size = doEntity.Size;//控制图案的大小
                            System.Drawing.Color color = doEntity.Color;//控制图案的颜色
                            vtkGlyphSource2DDrawType drawType = GetGlyphDrawType(doEntity.DisplayShape);
                            headFilter.SetVTKGlyphSource2DData(isUse, size, color, drawType);

                        }
                    }

                    break;
                case ModFlowNodeIDManager.gridWell:

                    GeometryNode gnWell = (GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridWell.ToString());
                    if (gnWell != null)
                    {
                        ShowWellFilter wellFilter = (ShowWellFilter)gnWell.GetFilter(FilterIDManager.showWellFilter.ToString());
                        if (wellFilter != null)
                        {
                            bool isUse = doEntity.Enabled;//是不是控制  Actor 的可见性
                            int size = doEntity.Size;//控制图案的大小
                            System.Drawing.Color color = doEntity.Color;//控制图案的颜色
                            vtkGlyphSource2DDrawType drawType = GetGlyphDrawType(doEntity.DisplayShape);
                            wellFilter.SetVTKGlyphSource2DData(isUse, size, color, drawType);
                        }
                    }

                    break;
                case ModFlowNodeIDManager.gridRiver:
                    GeometryNode gnRiver = (GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridRiver.ToString());
                    if (gnRiver != null)
                    {
                        ShowRiverFilter riverFilter = (ShowRiverFilter)gnRiver.GetFilter(FilterIDManager.showRiverFilter.ToString());
                        if (riverFilter != null)
                        {
                            bool isUse = doEntity.Enabled;//是不是控制  Actor 的可见性
                            int size = doEntity.Size;//控制图案的大小
                            System.Drawing.Color color = doEntity.Color;//控制图案的颜色
                            vtkGlyphSource2DDrawType drawType = GetGlyphDrawType(doEntity.DisplayShape);
                            riverFilter.SetVTKGlyphSource2DData(isUse, size, color, drawType);
                        }
                    }

                    break;
                case ModFlowNodeIDManager.gridDrain:
                    GeometryNode gnDrain = (GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridDrain.ToString());
                    if (gnDrain != null)
                    {
                        ShowDrainFilter drainFilter = (ShowDrainFilter)gnDrain.GetFilter(FilterIDManager.showDrainFilter.ToString());
                        if (drainFilter != null)
                        {
                            bool isUse = doEntity.Enabled;//是不是控制  Actor 的可见性
                            int size = doEntity.Size;//控制图案的大小
                            System.Drawing.Color color = doEntity.Color;//控制图案的颜色
                            vtkGlyphSource2DDrawType drawType = GetGlyphDrawType(doEntity.DisplayShape);
                            drainFilter.SetVTKGlyphSource2DData(isUse, size, color, drawType);
                        }
                    }

                    break;
                case ModFlowNodeIDManager.gridGeneralHead:
                    GeometryNode gnGeneralHead = (GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridGeneralHead.ToString());
                    if (gnGeneralHead != null)
                    {
                        ShowGeneralHeadFilter generalHeadFilter = (ShowGeneralHeadFilter)gnGeneralHead.GetFilter(FilterIDManager.showGeneralHead.ToString());
                        if (generalHeadFilter != null)
                        {
                            bool isUse = doEntity.Enabled;//是不是控制  Actor 的可见性
                            int size = doEntity.Size;//控制图案的大小
                            System.Drawing.Color color = doEntity.Color;//控制图案的颜色
                            vtkGlyphSource2DDrawType drawType = GetGlyphDrawType(doEntity.DisplayShape);
                            generalHeadFilter.SetVTKGlyphSource2DData(isUse, size, color, drawType);
                        }
                    }

                    break;
                case ModFlowNodeIDManager.gridSpedifiedHead:
                    GeometryNode gnSpecifiedHead = (GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridSpedifiedHead.ToString());
                    if (gnSpecifiedHead != null)
                    {
                        ShowSpecifiedHeadFilter specifiedHeadFilter = (ShowSpecifiedHeadFilter)gnSpecifiedHead.GetFilter(FilterIDManager.showSpecifiedHead.ToString());
                        if (specifiedHeadFilter != null)
                        {
                            bool isUse = doEntity.Enabled;//是不是控制  Actor 的可见性
                            int size = doEntity.Size;//控制图案的大小
                            System.Drawing.Color color = doEntity.Color;//控制图案的颜色
                            vtkGlyphSource2DDrawType drawType = GetGlyphDrawType(doEntity.DisplayShape);
                            specifiedHeadFilter.SetVTKGlyphSource2DData(isUse, size, color, drawType);
                        }
                    }

                    break;

                case ModFlowNodeIDManager.gridPlaneBarrier:


                    GeometryNode gnBarrier = (GeometryNode)vtkScene.GetNode(ModFlowNodeIDManager.gridPlaneBarrier.ToString());
                    if (gnBarrier != null)
                    {
                        ShowPlaneBarrierFilter planeBarrierFilter = (ShowPlaneBarrierFilter)gnBarrier.GetFilter(FilterIDManager.showPlaneBarrierFilter.ToString());
                        if (planeBarrierFilter != null)
                        {
                            bool isUse = doEntity.Enabled;//是不是控制  Actor 的可见性
                            int size = doEntity.Size;//控制图案的大小
                            System.Drawing.Color color = doEntity.Color;//控制图案的颜色

                            planeBarrierFilter.UpdateBarrierSetup(isUse, size, color);

                        }
                    }



                    break;


                default:


                    break;

            }





        }



        #endregion





        #region 内部方法


        private static vtkGlyphSource2DDrawType GetGlyphDrawType(DisplayShape displayShape)
        {

            vtkGlyphSource2DDrawType drawType;

            switch (displayShape)//图案形状
            {
                #region

                case DisplayShape.Square:

                    drawType = vtkGlyphSource2DDrawType.Square;

                    break;
                case DisplayShape.Circle:

                    drawType = vtkGlyphSource2DDrawType.Circle;

                    break;
                case DisplayShape.Diamond:

                    drawType = vtkGlyphSource2DDrawType.Diamond;

                    break;
                case DisplayShape.TriangleUp:

                    drawType = vtkGlyphSource2DDrawType.TriangleUp;

                    break;
                case DisplayShape.Line:

                    drawType = vtkGlyphSource2DDrawType.Line;

                    break;
                case DisplayShape.DottedLine:

                    drawType = vtkGlyphSource2DDrawType.DottedLine;

                    break;
                default:

                    //默认赋值
                    drawType = vtkGlyphSource2DDrawType.Square;

                    break;

                #endregion
            }

            return drawType;

        }


        #endregion


    }
}
